package com.vlin.message.handler.tuya;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSONObject;
import com.vlin.constains.TuyaConstains;
import com.vlin.mapper.device.DeviceMapper;

public class NameUpdateHandler extends OtherTuyaMessageHandler {

	@Autowired
	private DeviceMapper deviceMapper;
	
	@Override
	public boolean otherSupport(String code, JSONObject object) {
		if(TuyaConstains.TUYA_NAME_UPDATE.equalsIgnoreCase(code)) {
			return true;
		}
		return false;
	}

	@Override
	public void otherHandler(String code, JSONObject bizData, JSONObject object) {
		String did = bizData.getString("devId");
		String name = bizData.getString("name");
		deviceMapper.updateNameByDid(did, name);
		
	}

}
